package com.yuxinyang.memory.admin.user.service.impl;


import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yuxinyang.memory.admin.common.ResponseProtocol;
import com.yuxinyang.memory.admin.common.SimpleDeferredResultHandler;
import com.yuxinyang.memory.admin.user.dao.MemoryUserDao;
import com.yuxinyang.memory.admin.user.model.MemoryUser;
import com.yuxinyang.memory.admin.user.service.MemoryUserService;
import org.springframework.stereotype.Service;
import org.springframework.web.context.request.async.DeferredResult;

import javax.annotation.Resource;
import java.util.List;
import java.util.UUID;

/**
 * <p>
 * 用户表 服务实现类
 * </p>
 *
 * @author 余秀良
 * @since 2019-08-29
 */
@Service
public class MemoryUserServiceImpl extends ServiceImpl<MemoryUserDao, MemoryUser> implements MemoryUserService {
    @Resource
    private SimpleDeferredResultHandler handler;

    /**
     * 用户列表
     *
     * @return 返回用户列表
     */
    @Override
    public DeferredResult<ResponseProtocol> userList() {
        DeferredResult<ResponseProtocol> deferredResult = new DeferredResult<>();
        List<MemoryUser> list = list();
        ResponseProtocol ok = ResponseProtocol.ok(list);
        deferredResult.setResult(ok);
        handler.process(UUID.randomUUID().toString().replace("-", ""), deferredResult);
        return deferredResult;
    }
}
